﻿using AbpApplication.AppServices;
using AbpApplication.InPut;
using AbpEntityFrameworkcore.DbContext;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using System.Runtime.Intrinsics.X86;
using System.Security.Claims;

namespace AbpWebapi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class UserController : ControllerBase
    {

        private readonly MyUserService service;

        public UserController(MyUserService service)
        {
            this.service = service;
        }



        [HttpPost]
        public async Task<ApiResponse> RegisterUser(InPut_UserService inPut) => await service.RegisterUser(inPut);
        [HttpPost]
        public async Task<ApiResponse> LoginUser(InPut_UserService2 inPut)=>await service.LoginUser(inPut);
        [HttpPost]
        [Authorize(Roles = "管理员")]
        public async Task<ApiResponse> UpdatePassWord(InPut_UserService3 inPut)=>await service.UpdatePassWord(inPut);
        [HttpPost]
        [Authorize(Roles = "管理员")]
        public async Task<ApiResponse> UpdateUserInfo(InPut_UserService4 inPut)=>await  service.UpdateUserInfo(inPut);
        [HttpPost]
        [Authorize(Roles = "管理员")]
        public async Task<ApiResponse> FindOneUserInfo(string UserName)=>await service.FindOneUserInfo(UserName);
        [HttpPost]
        [Authorize(Roles = "管理员")]
        public async Task<ApiResponse> UpdateRole(InPut_UserService5 inPut)=>await service.UpdateRole(inPut);
        [HttpPost]
        [Authorize]
        public async Task<ApiResponse> GetUserInfo()
        {
          var cliaim=   this.User.FindFirst(ClaimTypes.Name);
          return new ApiResponse("cliaim",true,cliaim.Value);
        }
    
 
    }
}
